{% load i18n %}

<h2>{% trans 'Prices' %}</h2>
<form action="{% url lfs_manage_add_payment_price payment_method.id %}"
      method="post">
    <input type="text" name="price" /> 
    <input class="ajax-save-button button" 
           type="submit" 
           value="{% trans 'Add price' %}" />
</form>

{% if prices %}
    <h2 class="heading-middle">{% trans 'Existing prices' %}</h2>
    <form action="{% url lfs_manage_update_payment_prices payment_method.id %}"
          method="post">
        <table>
            <tr>
                <th>
                    <input type="checkbox" 
                           class="select-all" 
                           value="prices" />
                </th>
                <th>
                    {% trans 'Priority' %}
                </th>
                <th>
                    {% trans 'Price' %}
                </th>
            </tr>
            {% for price in prices  %}
            <tr>
                <td>
                    <input type="checkbox" name="delete-{{ price.id }}" class="select-prices" />
                </td>
                <td>
                    <input type="text" size="5" name="priority-{{ price.id }}" value="{{ price.priority }}" />
                </td>
                <td>
                    <div>
                        <input type="text" name="price-{{ price.id }}" value="{{ price.price }}" />
                        <a href="{% url lfs_manage_payment_price_criteria price.id %}"
                           class="ajax-link">
                           {% trans 'Edit criteria' %}
                        </a>                        
                    </div>
                    {% for criterion_object in price.criteria_objects.all %}
                        <div style="padding-left:3px">
                            {{ criterion_object.criterion }}
                        </div>
                    {% endfor %}
                </td>
            </tr>
            {% endfor %}
            <tr>
                <td></td>
                <td colspan="2">
                    <div class="buttons">
                        <input class="ajax-save-button button" type="submit" name="delete" value="{% trans 'Delete prices' %}" />
                        <input class="ajax-save-button button" type="submit" name="update" value="{% trans 'Update prices' %}" />
                    </div>
                </td>
            </tr>
        
        </table>
    </form>
{% endif %}